package com.xxy.partnermatch.common;

import com.xxy.partnermatch.model.enums.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/**
 * ClassName: BaseResponse
 * Package: com.xxy.usercenter.common
 * Description: 封装通用的返回对象
 *
 * @Author 十一
 * @Create 2024/11/14 16:02
 * @Version 1.0
 */
@Data
public class BaseResponse<T> implements Serializable {

    /**
     * 状态码
     */
    private int code;

    /**
     * 内容
     */
    private T data;

    /**
     * 消息
     */
    private String message;

    /**
     * 详细描述
     */
    private String description;

    /**
     * 构造函数
     * @param code 状态码
     * @param data 内容
     * @param message 消息
     * @param description 详细描述
     */
    public BaseResponse(int code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public BaseResponse(int code, T data) {
        this(code, data, "", "");
    }

    public BaseResponse(int code, T data, String message) {
        this(code, data, message, "");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage(), errorCode.getDescription());
    }

}
